#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Time       :   11:44
# Author     : Y4
# Site       : 
# File       : index.py
import math

'''
超市收银
'''


# 创建算法家族的抽象类
class CashSuper():
    def getResult(self):
        pass


# 正常收费
class CashNormal(CashSuper):
    def getResult(self, money):
        return money


# 打折收费
class CashRebate(CashSuper):
    def __init__(self, rebate):
        self.rebate = rebate

    def getResult(self, money):
        return money * self.rebate


# 满多少返多少收费 (满300-100)
class CashReturn(CashSuper):
    def __init__(self, moneyTotal, moneyReturn):
        self.moneyTotal = moneyTotal
        self.moneyReturn = moneyReturn

    def getResult(self, money):
        result = money
        if money >= self.moneyTotal:
            result = money - (money / self.moneyTotal) * self.moneyReturn
        return result


class CashContent():
    def __init__(self, cs):
        self.cs = cs

    def jisuan(self, money):
        return self.cs.getResult(money)


if __name__ == '__main__':
    cashRebate = CashRebate(0.8)

    cashContent = CashContent(cashRebate)

    result = cashContent.jisuan(100)

    print(result)
